<template>
  <div>
    <!--     <van-field v-model="text" label="物品用途" />
        <van-field v-model="tel" type="text" label="未完成工作" />
        <van-field v-model="digit" type="text" label="物品名称" />
        <van-field v-model="digit" type="text" label="数量" />-->
    <van-nav-bar
      title="物品领用"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <van-form @submit="onSubmit">
      <van-field
        v-model="data.adtrtReson"
        name="用户名"
        label="物品用途"
        placeholder="请输入"
        :rules="[{ required: true, message: '物品用途' }]"
      />
      <van-field
        v-model="data.adtrtName"
        name="用户名"
        label="物品名称"
        placeholder="请输入"
        :rules="[{ required: true, message: '物品名称' }]"
      />  <van-field
      v-model="data.adtrtCount"
      name="用户名"
      label="数量"
      placeholder="请输入"
      :rules="[{ required: true, message: '数量' }]"
    />
      <div style="margin: 16px;">
        <van-button round block type="info" native-type="submit">
          提交
        </van-button>
      </div>
    </van-form>

  </div>
</template>

<script>
  import {Toast} from "vant";
  import Administrative from "@/api/Administrative";

  export default {
    data() {
      return {
        data: {
          adtrtName: '',
          adtrtCount: '',
          adtrtReson: '',
        },
      };
    },
    methods: {
      onClickLeft() {
        this.$router.push('/work')
      },
      onSubmit() {
        Toast.loading({
          message: '提交中...',
          forbidClick: true,
        });

        Administrative.insertGoods({
          userId:this.$store.getters.userInfo.userId,
          adtrtType: 1, //行政类型（1：物品领用，2：用车申请，3：永章申请）
          // status: 1 //审核状态（1：通过，2：未审核
          adtrtName:this.data.adtrtName,
          adtrtCount: this.data.adtrtCount,
          adtrtReson: this.data.adtrtReson,

        })
          .then(res => {
            // 返回数据
            Toast.success('提交成功');
            this.data.adtrtName = '';
            this.data.adtrtCount = '';
            this.data.adtrtReson = '';
          })
          .catch(err => {
            // 异常情况
          })
      },
    }
  }
</script>

<style scoped>

</style>
